/*   Shotscreens
 *   Copyright (C) 2011, Andrew Lisin (http://crystalnix.com)
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "settings.h"
#include <QKeySequence>
#include <QSettings>
#include <QString>

Settings::Settings() : settings(new QSettings("Crystalnix", "ShotScreens"))
{
}

Settings::~Settings()
{
    delete settings;
}

Settings& Settings::instance()
{
    static Settings sw;
    return sw;
}

QKeySequence Settings::getKey()
{
    return settings->value("/Hotkey/key", QVariant::fromValue(QKeySequence("F8"))).value<QKeySequence>();
}

void Settings::setKey(const QKeySequence &key)
{
    settings->setValue("/Hotkey/key", key);
}

QString Settings::getLogin()
{
    return settings->value("/UserInfo/login", "").toString();
}

void Settings::setLogin(const QString &login)
{
    settings->setValue("/UserInfo/login", login);
}

QString Settings::getPassword()
{
    return settings->value("/UserInfo/password", "").toString();
}

void Settings::setPassword(const QString &password)
{
    settings->setValue("/UserInfo/password", password);
}

QString Settings::getUploader()
{
    return settings->value("/Uploader/uploader", "").toString();
}

void Settings::setUploader(const QString &uploader)
{
    settings->setValue("/Uploader/uploader", uploader);
}

QString Settings::getPluginName()
{
    return settings->value("/Plugin/PluginName","").toString();
}

//void Settings::setPluginFileName(const QString &pluginFileName)
//{
//    settings->setValue("/Plugin/PluginPath", pluginFileName);
//}

//QString Settings::getPluginFileName()
//{
//    return settings->value("/Plugin/PluginPath", "").toString();
//}

void Settings::setPluginName(const QString &pluginName)
{
    settings->setValue("/Plugin/PluginName", pluginName);
}

void Settings::setValue(QString key, QVariant value)
{
    key = QString("Plugins/") + this->getPluginName() + QString("/") + key;
    settings->setValue(key, value);
}
